<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Document</title>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link href="../assets/mobile/goods.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script src="../assets/js/mobile/GoodsPicSlider.js" type="text/javascript"></script>
<script src="../assets/js/mobile/PeriodSlider.js" type="text/javascript"></script>
</head>
<body>
<!--通用顶部-->

<!--通用顶部结束-->
<section class="scroller create_goods" style="margin-top:0px !important;">
	
<!--轮播器开始-->		
      <div class="pPic pPicBor" style="padding:5px 0px;">
          <div class="pPic2">
  	        <div id="sliderBox" class="pImg">
                  <div class="comm-loading" style="background:#f4f4f4;"><em>正在加载</em></div>
                  <ul class="slides">
				<li><img class="lazy" data-original="" class="animClass" /></li>
                  </ul>
              </div>
          </div>
      </div>
<!--轮播器结束-->
   <ul class="listitem count_goods">
       <li>
       	<div class="text">
            <p><span class="jinxing"></span><font>加载中...</font></p>
           	<p><span class="money">市场价： ￥ 0.00</span><span class="goods_num" style="float:right;">送出：加载中...</span></p>
			<p><span class="left">商城价：<font>加载中...</font></span></p>
			<p><span class="freight" style="float:right;">运费：<font>加载中...</font></span></p>
		</div>
       </li>
   </ul>
		<form class="get_buy_form group_buy_form" style="border-bottom:1px dashed #eee;">
		<input type="hidden" value="" name="goods_id"/>
		<input type="hidden" value="" name="price"/>
			<ul>
				<li>
					<span style="margin-top:7px;">数量：</span>
					<p style="display:inline-block;">
					<span class="cart_btn cut_down">-</span>
					<input type="text" name="num" value="1" class="cart_group_num" id="num" />
					<span class="cart_btn add_num">+</span>
					</p>
				</li>
				<li>
					<button class="common-btn" id="z_addCart" style="width:95%;margin:5px auto 0 auto;font-size:20px;">立即购买</button>
					
				</li>
			</ul>
		</form>
		<ul class="table-view" style="border-bottom:0px;">
			  <li class="table-view-cell">
			    <a class="navigate-right" id="z_desc" href="javascript:;" style="font-size:13px;">图片详情</a>
			  </li>
		</ul>
		<div class="detail-content"  style="display:none;padding:0px 10px 10px 10px;overflow-x:hidden;">加载中...</div>
		
		<div class="block10"></div>
</section>

<script type="text/javascript">
apiready = function(){
$(function(){
	var goods_id = localData.get('z_goods_id');
	if(!goods_id){
		api.alert({msg:'参数错误'});
		return;
	}
  function loadscroller(){
      $("#divPeriod").touchslider();
      $("#sliderBox").picslider();
  }
  $('#z_desc').click(function(){
  	api.openWin({name:'z_desc','url':'./z_desc.html',reload:true});
  });
	GetJPData(config.url+'/app.php?act=z_item&goods_id='+goods_id,{},function(data){
		if(data['status'] == 1){
			$('.comm-loading').remove();
	        var imgs = '';
	        for(var i in data['item']['picarr']){
	            imgs += '<li><img src="'+config.upload_url+'/'+data['item']['picarr'][i]+'" class="animClass" /></li>';
	        }
	        if(data['item']['picarr'] == ''){
	            imgs += '<li><img src="'+config.upload_url+'/'+data['item']['thumb']+'" class="animClass" /></li>';
	        }
	        $('.pImg .slides').html(imgs);
	        loadscroller();
	        //str = data['item']['content'].replace(/src=/g,'class="lazy" data-original=');
	        //$('.detail-content').html(str);
	        //$('.detail-content img.lazy').lazyload({effect: "fadeIn"});
	        var titlehtml = data['item']['title']+'<span> <font style="'+data['item']['title_style']+'">'+data['item']['title2']+'</font></span>';
			$('.jinxing').next().html(titlehtml);
	        $('.money').html('市场价：<del>￥'+data['item']['oldmoney']+'</del>');
	        $('span.goods_num').text('送出：'+data['item']['canyurenshu']);
	        $('p span.left font').text(data['item']['money']);
	        $('input[name=goods_id]').val(data['item']['id']);
	        $('input[name=price]').val(data['item']['money']);
	        $('.freight font').text(data['item']['yunjiage']);
	    	var goods_num = data['item']['shenyurenshu'];
	    	if(goods_num <= 0){
	    		$('.common-btn').attr('id','fdasf').css('background','#999').text('缺货中...');
	    		return;
	    	}
	    	if(data['item']['money']!='0.00'){
				localData.set('keyf','jfgoods');
			}else{
				localData.set('keyf','ne');
			}
	    	$('.cut_down').click(function(){
	    		var num = parseInt($('#num').val());
	    		if(isNaN(num)){
	    			$('#num').val(1);
	    			return;
	    		}
	    		if(num <= 1){
	    			api.alert({title:'',msg:'商品数量不能小于1'});
	    		}else{
	    			$('#num').val(--num);
	    		}
	    	});
	    	$('.add_num').click(function(){
	    		var num = parseInt($('#num').val());
	    		if(isNaN(num)){
	    			$('#num').val(1);
	    			return;
	    		}
	    		++num
	    		if(num > goods_num){
	    			api.alert({title:'',msg:'商品数量不能大于'+goods_num});
	    		}else{
	    			$('#num').val(num);
	    		}
	    	});
	    	$('#num').keydown(function(){
	    		setTimeout(function(){
		    		var num = parseInt($('#num').val());
		    		if(isNaN(num)){
		    			$('#num').val(1);
		    			return;
		    		}
		    		if(num >= goods_num){
		    			$.PageDialog.fail('最多能购买'+goods_num+'件');
		    			$('#num').val(goods_num);
		    		}else{
		    			$('#num').val(num);
		    		}
	    		},30);
	    	});
	    	
	    	$('#z_addCart').click(function(){
	    		var goods_id = $('input[name=goods_id]').val();
	    		var num = parseInt($('#num').val());
	    		var price = $('input[name=price]').val();
	    		//如果不是数字
	    		if(isNaN(num)){
	    			num = 1;
	    		}
	    		if (num >= 1 && num <= goods_num){
	    			z_addCart(goods_id,price,num);
	    			setTimeout(function(){
	    				api.openWin({name:'z_cart','url':'./z_cart.html',reload:true});
	    			},1500);
	    			return false;
	    		}
	    		return false;
	    	});
	        
		}else{
			api.alert({title:'',msg:data['msg']});
		}
	});
	
});
};

</script>
</body>
</html>